package com.meilele.dao.czh;

import com.meilele.entity.czh.FiveDesign;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;
@Repository
public interface FiveDesignMapper {
    @Delete({
        "delete from five_design",
        "where design_id = #{designId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer designId);

    @Delete({
            "delete from five_design",
            "where company_id = #{companyId,jdbcType=INTEGER}"
    })
    int deleteByPrimarycompanyId(Integer companyId);


    @Insert({
        "insert into five_design (design_id, design_name, ",
        "design_city, design_produce, ",
        "design_logo, design_signature, ",
        "company_id, design_file)",
        "values (#{designId,jdbcType=INTEGER}, #{designName,jdbcType=VARCHAR}, ",
        "#{designCity,jdbcType=VARCHAR}, #{designProduce,jdbcType=VARCHAR}, ",
        "#{designLogo,jdbcType=VARCHAR}, #{designSignature,jdbcType=VARCHAR}, ",
        "#{companyId,jdbcType=INTEGER}, #{designFile,jdbcType=LONGVARCHAR})"
    })
    int insert(FiveDesign record);

    int insertSelective(FiveDesign record);

    @Select({
        "select",
        "design_id, design_name, design_city, design_produce, design_logo, design_signature, ",
        "company_id, design_file",
        "from five_design",
        "where design_id = #{designId,jdbcType=INTEGER}"
    })
    @ResultMap("com.meilele.dao.czh.FiveDesignMapper.ResultMapWithBLOBs")
    FiveDesign selectByPrimaryKey(Integer designId);

    @Select({
            "select",
            "design_id, design_name, design_city, design_produce, design_logo, design_signature, ",
            "company_id, design_file",
            "from five_design",
            "where design_id = #{designId,jdbcType=INTEGER}"
    })
    @ResultMap("com.meilele.dao.czh.FiveDesignMapper.ResultMapWithBLOBs")
    FiveDesign selectByPrimaryId(Integer designId);

    @Select({
            "select",
            "design_id, design_name, design_city, design_produce, design_logo, design_signature, ",
            "company_id, design_file",
            "from five_design",
            "where design_city = #{designCity,jdbcType=VARCHAR} limit ${firstPage}, ${resultPage}"
    })
    @ResultMap("com.meilele.dao.czh.FiveDesignMapper.ResultMapWithBLOBs")
    List<FiveDesign> selectByPrimaryCity(@Param("designCity") String designCity,@Param("firstPage") int firstPage, @Param("resultPage") int resultPage);

    @Select({
            "select",
            "count(design_id)",
            "from five_design where design_city=#{designCity,jdbcType=VARCHAR}"
    })
    int findCount(String designCity);
    @Select({
            "select",
            "design_id, design_name, design_city, design_produce, design_logo, design_signature, ",
            "company_id, design_file",
            "from five_design limit #{firstPage},#{resultPage}"

    })
    @ResultMap("com.meilele.dao.czh.FiveDesignMapper.ResultMapWithBLOBs")
    List<FiveDesign> selectByPrimaryAll(@Param("firstPage")int firstPage,@Param("resultPage")int resultPage);


    @Select({
            "select",
            "design_id, design_name, design_city, design_produce, design_logo, design_signature, ",
            "company_id, design_file",
            "from five_design "

    })
    @ResultMap("com.meilele.dao.czh.FiveDesignMapper.ResultMapWithBLOBs")
    List<FiveDesign> selectByPrimaryAlla();



//    @Select({
//            "select",
//            "design_id, design_name, design_city, design_produce, design_logo, design_signature, ",
//            "company_id, design_file",
//            "from five_design "
//
//    })
//    @ResultMap("com.meilele.dao.czh.FiveDesignMapper.ResultMapWithBLOBs")
//    List<FiveDesign> selectByPrimaryAll();

    int updateByPrimaryKeySelective(FiveDesign record);

    @Update({
        "update five_design",
        "set design_name = #{designName,jdbcType=VARCHAR},",
          "design_city = #{designCity,jdbcType=VARCHAR},",
          "design_produce = #{designProduce,jdbcType=VARCHAR},",
          "design_logo = #{designLogo,jdbcType=VARCHAR},",
          "design_signature = #{designSignature,jdbcType=VARCHAR},",
          "company_id = #{companyId,jdbcType=INTEGER},",
          "design_file = #{designFile,jdbcType=LONGVARCHAR}",
        "where design_id = #{designId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKeyWithBLOBs(FiveDesign record);

    @Update({
        "update five_design",
        "set design_name = #{designName,jdbcType=VARCHAR},",
          "design_city = #{designCity,jdbcType=VARCHAR},",
          "design_produce = #{designProduce,jdbcType=VARCHAR},",
          "design_logo = #{designLogo,jdbcType=VARCHAR},",
          "design_signature = #{designSignature,jdbcType=VARCHAR},",
          "company_id = #{companyId,jdbcType=INTEGER}",
        "where design_id = #{designId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(FiveDesign record);


    @Select({
            "select",
            "count(design_id)",
            "from five_design"
    })
      int findcont();

}